#ifndef SENDER_H
#define SENDER_H

#include "signal_watcher.h"
#include <list>

class sender {
public:
    MAKE_NONCOPYABLE(sender);
    sender(uv_loop_t* loop, pid_t pid): sw_(nullptr), loop_(loop), pid_(pid), send_num_(0) , recv_num_(0){
        memset(&timer_, 0x00, sizeof(timer_));
        timer_.data = this;

        memset(&idle_, 0x00, sizeof(idle_));
        idle_.data = this;
    }
    int watch_signals();
    void handle_signal(const signalfd_siginfo*);
    int test_start();
    int test_start(int);
    int test_stop();

private:
    int send_signal(int dest_pid, int signo);
    template<typename T>
    static void timer_cb(T* handle);

private:
    signal_watcher* sw_;
    uv_loop_t* loop_;
    uv_timer_t timer_;
    uv_idle_t  idle_;
    pid_t pid_; //dest pid
    int send_num_;
    int recv_num_;
    std::list<long> timestamp_;
};

#endif // SENDER_H 
